<%--
  Created by IntelliJ IDEA.
  User: liuxi
  Date: 2018/5/30
  Time: 17:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/bootstrap/css/bootstrap.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/table/bootstrap-table.min.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/date/bootstrap-datetimepicker.min.css"/>
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/statics/sweetalert.css"/>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/statics/sweetalert.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/jquery-3.2.1.min.js"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/statics/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/statics/table/bootstrap-table.min.js"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/statics/table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/date/Moment.js"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/statics/date/bootstrap-datetimepicker.min.js"></script>
</head>
<body>
<div class="panel panel-default">
    <div class="panel-body">
        <form class="form-inline">
            <div class="form-group">
                医生：<input id="nName" name="title" type="text" class="form-control" placeholder="搜索内容">
            </div>
            就诊日期:
            <div class="input-group input-daterange">
                <input id="cVisitTime" type="text" class="form-control">
                <span class="input-group-addon">
                    <span class="glyphicon glyphicon-calendar"></span>
                </span>
            </div>
            <button onclick="search()" type="button" class="btn btn-default">查询</button>
        </form>
    </div>
</div>



<table id="table" class="" ></table>


</body>
<script type="text/javascript">


    window.operateEvents = {

    };


    function queryParams(params) {
        var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
            pageSize: params.pageSize,  //页面大小
            pageNumber: params.pageNumber, //页码
            nName: $("#nName").val(),
            cVisitTime: $("#cVisitTime").val(),
        };
        return temp;
    }

    function search() {
        var opts = $("#table").bootstrapTable('getOptions');
        var nName = $("#nName").val();
        var cVisitTime = $("#cVisitTime").val();
        $.ajax({
            "url": "${pageContext.request.contextPath}/case/query",
            "type": "post",
            "data": {
                "nName": nName,
                "cVisitTime": cVisitTime,
                "pageNumber": opts.pageNumber,
                "pageSize": opts.pageSize
            },
            "dataType": "json",
            "success": function (data) {
                $("#table").bootstrapTable('load', data);
            }
        })
    }

    $(function(){

        // 时间插件
        $('#cVisitTime').datetimepicker({
            //viewMode: 'day',
            format: 'YYYY-MM-DD'
        });


        //bootstrapTable
        $("#table").bootstrapTable({
            url: '${pageContext.request.contextPath}/case/query',
            columns: [{
                field: 'cid',
                title: '病例编号'
            }, {
                field: 'pName',
                title: '患者姓名'
            }, {
                field: 'cVisitTime',
                title: '就诊时间'
            }, {
                field: 'cvisitProjet',
                title: '就诊项目'
            }, {
                field: 'ccompld',
                title: '主诉'
            }, {
                field: 'cdiagnosisInfo',
                title: '诊断信息'
            }, {
                field: 'creviewIstrue',
                title: '是否需要复查',
                formatter:function (index, row, value) {
                    if(row.creviewIstrue==0){
                        return '不需要';
                    }else{
                        return '需要'
                    }
                }
            }, {
                field: 'cReviewTime',
                title: '建议复查时间',
                formatter:function (index, row, value) {
                    if(row.cReviewTime==null){
                        return '不需要'
                    }else{
                        return row.cReviewTime;
                    }
                }
            }, {
                field: 'cproposal',
                title: '建议'
            }, {
                field: 'nName',
                title: '就诊医生'
            }, {
                title: '操作',
                events: operateEvents,
                formatter: caozuo
            }],
            method: 'post',
            contentType: "application/x-www-form-urlencoded",
            height: 500,
            pageList: [5, 10, 15],
            pageSize: 5,
            sortable: true,
            sortOrder: "asc",
            pageNumber: 1,
            pagination: true,
            queryParamsType: '',
            queryParams: queryParams,
            sidePagination: 'server'
        });
        function caozuo(value, row, index) {
            return [
                "<a class='update' href=javascript:update(" + row.cid + ")>修改</a>"
            ].join("");
        }
    });



</script>
</html>
